/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rnavizexperimentation;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Elias la Cour
 */
public class MyCircle extends JPanel {

    private static int CANVAS_SIZE = 512;
    private char[] sequence;
    private int n;
    private char[] knots;

    MyCircle(Structure s) {
        //super(true);
        sequence = s.getBaseSequence();
        knots = s.getDotSequence();
        this.setPreferredSize(new Dimension(CANVAS_SIZE, CANVAS_SIZE));
    }

    @Override
    protected void paintComponent(Graphics g) {

        super.paintComponent(g);//calls the paintComponent of superclass 
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(
                RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        int xMiddle;
        int yMiddle;
        xMiddle = getWidth() / 2;
        yMiddle = getHeight() / 2;
        int m = Math.min(xMiddle, yMiddle);
        //? rbruges til at udregne omkreds af cirklen?
        int r = 4 * m / 5;
        //g2d.drawOval(a - r, b - r, 2 * r, 2 * r);
        g2d.setColor(Color.blue);

        Double theta;
        int n = sequence.length;

        for (int i = 0; i < n; i++) {
            theta = (2 * Math.PI * i) / n;
            int x = (int) Math.round(xMiddle + r * Math.cos(theta));
            int y = (int) Math.round(yMiddle + r * Math.sin(theta));
            g2d.drawString(Character.toString(sequence[i]), x, y);

        }

//        for (int i = 0; i < n; i++) {
//            //t = theta
//            double t = 2 * Math.PI * i / n;
//            //cos finder nyt x coord, sin finder nyt y coord
//            int x = (int) Math.round(a + r * Math.cos(t));
//            int y = (int) Math.round(b + r * Math.sin(t));
//            g2d.drawString("b", x, y);
//            //g2d.fillOval(x - r2, y - r2, 2 * r2, 2 * r2);
//        }
    }

    private static void createLayout() {
        JFrame jf = new JFrame();
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.pack();
        jf.add(new MyCircle(new InputHandler().smallInput()));
        jf.setVisible(true);
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                createLayout();
            }
        });
    }
}
